﻿@using ProductSystem.BLL;
@{
    ViewBag.Title = "DefaultPage";
}
<link href="~/Content/css/bootstrap.css" rel="stylesheet" />
<link href="~/Content/css/font-awesome.min.css" rel="stylesheet" />
<link href="~/Content/css/home.css" rel="stylesheet" />
<script src="~/Content/js/jquery-1.10.1.min.js"></script>
<div class="home-content">
    <div class="desk-status">
        <div class="desk-status-header">
            <div class="table-num">
                <span>
                    <i class="c-empty"></i>
                    <b id="num-empty">@ViewData["EmptyCount"]</b>桌（空位）
                </span>
                <span>
                    <i class="c-using"></i>
                    <b id="num-using">@ViewData["DiningCount"]</b>桌（用餐中）
                </span>
                <span>
                    <i class="c-booked"></i>
                    <a id="show-frame-booked" href="#">
                        <b id="num-booked">@ViewData["BookedCount"]</b>桌（预订）
                    </a>
                </span>
            </div>
        </div>
    </div>
    <div class="desk-toolbar">
        <ul>
            <li class="booking">
                <i class="icon-phone"></i>预订
            </li>
            <li>
                <i class="icon-exchange"></i>换桌
            </li>
            <li>
                <i class="icon-adjust"></i>并单
            </li>
            <li>
                <i class="icon-signout"></i>退单
            </li>
            <li>
                <i class="icon-repeat"></i>刷新
            </li>
        </ul>
    </div>
    <div class="desklist" id="desklist">
        <ul>
            @foreach (Desk desk in Model)
            {
                string deskClass = string.Empty;
                switch (desk.Status)
                {
                    case (int)DeskStatusEnum.Empty:
                        break;
                    case (int)DeskStatusEnum.Dining:
                        deskClass = "using";
                        break;
                    case (int)DeskStatusEnum.Booked:
                        deskClass = "booked";
                        break;
                }
                <li class="@deskClass">
                    <div class="tab-chk">
                        <div class="icheckbox_square" id="@desk.ID" style="position: relative;">
                            <input type="checkbox" value="@desk.ID" data-t-name="" data-t-state="@desk.DeskNumber" style="position: absolute; opacity: 0;">
                            <ins style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins>
                        </div>
                    </div>
                    <h3>@desk.DeskNumber</h3>
                    <div class="tables-over"><span class="li-hover-btn"><a href="javascript:void(0);" onclick="GoPage('/Order/OrderAdd?DeskID=@desk.ID')">进入点餐</a></span></div>
                </li>
            }
        </ul>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $(".icheckbox_square").click(function () {
            $(this).toggleClass("checked");
        });
        //预订
        $(".booking").click(function () {
            var arrId = [];
            $(".icheckbox_square").each(function () {
                if ($(this).hasClass("checked")) {
                    arrId.push($(this).attr("id"));
                }
            });
            if (arrId.length == 0) {
                layer.msg('请选择一个空桌预订！', { icon: 5, time: 1000, shade: 0.3 });
            } else if (arrId.length > 1) {
                layer.msg('只允许选择一桌！', { icon: 2, time: 1000, shade: 0.3 });

            } else {
                AlertModelFrame('/Order/BookingAdd?ids=' + arrId.join(','), '预订餐桌');
                //AlertModelFrame('/Order/BookingAdd', '预订餐桌');
            }
        });
    });
</script>